﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Modulos/ModuloPrestamo/VistaControl/MasterPagePrestamo.master" AutoEventWireup="true" CodeFile="articulos.aspx.cs" Inherits="Modulos_ModuloPrestamo_VistaControl_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
Módulo de Préstamos - Administracíon de materiales de préstamo
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <h2>Administración de materiales de préstamo</h2><br />
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="MAT_P_ID" 
        DataSourceID="SqlDataSource1">
        <InsertItemTemplate>
            <table style="width: 100%" frame="box">
                <tr>
                    <td colspan="2">
                        Nuevo material de préstamo</td>
                </tr>
                <tr>
                    <td>
                        Nombre:</td>
                    <td>
                        <asp:TextBox ID="NOMBRE_MAT_PTextBox" runat="server" 
                            Text='<%# Bind("NOMBRE_MAT_P") %>' />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                            ControlToValidate="NOMBRE_MAT_PTextBox" Display="Dynamic" 
                            ErrorMessage="* campo obligatorio"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        Cantidad:</td>
                    <td>
                        <asp:TextBox ID="CANTIDAD_MAT_PTextBox" runat="server" 
                            Text='<%# Bind("CANTIDAD_MAT_P") %>' />
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                            ControlToValidate="CANTIDAD_MAT_PTextBox" ErrorMessage="* campo numérico" 
                            ValidationExpression="\d+" Display="Dynamic"></asp:RegularExpressionValidator>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                            ControlToValidate="CANTIDAD_MAT_PTextBox" Display="Dynamic" 
                            ErrorMessage="* campo obligatorio"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        Descripción:</td>
                    <td>
                        <asp:TextBox ID="DES_MAT_PTextBox" runat="server" 
                            Text='<%# Bind("DES_MAT_P") %>' />
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                    <td>
                        <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                        OnClientClick="javascript:if(!confirm('&iquest;Confirma insertar material?'))return false"
                            CommandName="Insert" Text="Insertar" />
                        &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                            CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
                    </td>
                </tr>
            </table>
        </InsertItemTemplate>
        <ItemTemplate>
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="Nuevo material de préstamo" />
        </ItemTemplate>
        <EmptyDataTemplate>
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="Nuevo material de préstamo" />
        </EmptyDataTemplate>
    </asp:FormView>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="MAT_P_ID"
        DataSourceID="SqlDataSource1" 
        EmptyDataText="No hay registros de datos para mostrar." AllowPaging="True" 
        AllowSorting="True">
        <Columns>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"
                        OnClientClick="javascript:if(!confirm('&iquest;Confirma actualizar material?'))return false" 
                        CommandName="Update" Text="Actualizar"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="Cancelar"></asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="Editar"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Delete" 
                        OnClientClick="javascript:if(!confirm('&iquest;Confirma eliminar material?'))return false"
                        Text="Eliminar"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="MAT_P_ID" HeaderText="Id" ReadOnly="True" SortExpression="MAT_P_ID" />
            <asp:TemplateField HeaderText="Nombre" SortExpression="NOMBRE_MAT_P">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("NOMBRE_MAT_P") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                        Display="Dynamic" ErrorMessage="* campo obligatorio" 
                        ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("NOMBRE_MAT_P") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Cantidad" SortExpression="CANTIDAD_MAT_P">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CANTIDAD_MAT_P") %>'></asp:TextBox>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="* campo numérico" ControlToValidate="TextBox1" ValidationExpression="\d*" Display="Dynamic"></asp:RegularExpressionValidator>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="* campo obligatorio" ControlToValidate="TextBox1" Display="Dynamic"></asp:RequiredFieldValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("CANTIDAD_MAT_P") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="DES_MAT_P" HeaderText="Descripción" 
                SortExpression="DES_MAT_P" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AppCeiiConnectionString %>"
        DeleteCommand="DELETE FROM [MATERIAL_PRESTAMO] WHERE [MAT_P_ID] = @MAT_P_ID"
        InsertCommand="INSERT INTO [MATERIAL_PRESTAMO] ([NOMBRE_MAT_P], [CANTIDAD_MAT_P], [DES_MAT_P]) VALUES (@NOMBRE_MAT_P, @CANTIDAD_MAT_P, @DES_MAT_P)"
        ProviderName="<%$ ConnectionStrings:AppCeiiConnectionString.ProviderName %>"
        SelectCommand="SELECT [MAT_P_ID], [NOMBRE_MAT_P], [CANTIDAD_MAT_P], [DES_MAT_P] FROM [MATERIAL_PRESTAMO]"
        UpdateCommand="UPDATE [MATERIAL_PRESTAMO] SET [NOMBRE_MAT_P] = @NOMBRE_MAT_P, [CANTIDAD_MAT_P] = @CANTIDAD_MAT_P, [DES_MAT_P] = @DES_MAT_P WHERE [MAT_P_ID] = @MAT_P_ID">
        <DeleteParameters>
            <asp:Parameter Name="MAT_P_ID" Type="Decimal" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="NOMBRE_MAT_P" Type="String" />
            <asp:Parameter Name="CANTIDAD_MAT_P" Type="Int32" />
            <asp:Parameter Name="DES_MAT_P" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="NOMBRE_MAT_P" Type="String" />
            <asp:Parameter Name="CANTIDAD_MAT_P" Type="Int32" />
            <asp:Parameter Name="DES_MAT_P" Type="String" />
            <asp:Parameter Name="MAT_P_ID" Type="Decimal" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>

